%% Analysis of Steady-State 25C vs. 37C BarSeq data from Feb. 18 2021 samples
load('EcoliBW25113_Tn_LB_steadystate_20200303.mat');
temp = Steadystates_Mar3;
close all;

%% Create plotting arrays
time_25C = [-15 0 10 20 30 40 60 90];
fitness_array_25C = [temp.setAIT04433_25to25_15min_B temp.setAIT04533_25to25_0min_B temp.setAIT04633_25to25_10min_B temp.setAIT04733_25to25_20min_B temp.setAIT04833_25to25_30min_B temp.setAIT04933_25to25_40min_B temp.setAIT05033_25to25_60min_B temp.setAIT05133_25to25_90min_B];

time_37C = [-10 10 20 30 40 60 90];
fitness_array_37C = [temp.setAIT06233_37to37_10min_B temp.setAIT06433_37to37_10min_B temp.setAIT06533_37to37_20min_B temp.setAIT06733_37to37_30min_B temp.setAIT06833_37to37_40min_B temp.setAIT06933_37to37_60min_B temp.setAIT07033_37to37_90min_B];

%% Plot 25C data
hits_25C = [];

figure;
for k=1:size(fitness_array_25C,1)
    if mean(abs(fitness_array_25C(k,:)))<1.5
        plot(time_25C, fitness_array_25C(k,:), 'color', [0.8 0.8 0.8 0.5]);
    else
        plot(time_25C, fitness_array_25C(k,:), 'b');
        hits_25C = [hits_25C; k];
        text(time_25C(end), fitness_array_25C(k,end), temp.genename(k));
    end
    hold on;
end
ylim([-6 2]);
set(gcf, 'Position', [0 0 400 300]);
set(gca,'fontsize', 20);
box off;
xlabel('Time (min)');
ylabel('Log2 fitness');
exportgraphics(gcf,'Steadystate_Feb18_25C.pdf','ContentType','vector');

%% Plot 37C data
hits_37C = [];

figure;
for k=1:size(fitness_array_37C,1)
    if mean(abs(fitness_array_37C(k,:)))<1.5
        plot(time_37C, fitness_array_37C(k,:), 'color', [0.8 0.8 0.8 0.5]);
    else
        plot(time_37C, fitness_array_37C(k,:), 'r');
        hits_37C = [hits_37C; k];
        text(time_37C(end), fitness_array_37C(k,end), temp.genename(k));
    end
    hold on;
end
ylim([-6 2]);
set(gcf, 'Position', [0 0 400 300]);
set(gca,'fontsize', 20);
box off;
xlabel('Time (min)');
ylabel('Log2 fitness');

%% Display hits
disp('25 to 25 hits');
temp.genename(hits_25C)
disp('37 to 37 hits');
temp.genename(hits_37C)
exportgraphics(gcf,'Steadystate_Feb18_37C.pdf','ContentType','vector');

